Learn to Code by Warren George

Learn to Code by Warren George

Author:Warren George [George, Warren]
Language: eng
Format: azw3
Published: 2018-12-05T16:00:00+00:00


Notes:

Introduce mouseX and mouseY. The circle will follow the mouse round the screen.

Mini challenges:

Can you make the circle move twice as fast as the mouse?

Can you make the circle move in the opposite direction to the mouse? Hint: width-mouseX, height-mouseY

Key words:

mouseX gives the x position of the mouse

mouseY gives the y position of the mouse

Sketch A3-2 (stretchy rectangle)

Code:

function setup()

{

createCanvas(800, 600);

}

function draw()

{

background(255);

fill(100);

rect(0, 200, mouseX, 200);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.